Android: keep direction_* drawables from resource shrinking#945
Open
freszu wants to merge 1 commit into
Open
Conversation
ManeuverIcon resolves the direction_* drawables at runtime via Resources.getIdentifier, which the AGP resource shrinker cannot trace. Ship a tools:keep rule in the ui-shared AAR so the icons survive consumer builds with shrinkResources enabled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
format lint will fail - its broken on main - in #944 i've fixed it won't be touching this in that PR - its pure android change |
freszu
marked this pull request as ready for review
July 23, 2026 14:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note! it looks like it starts happening when switching to AGP 9
before there was a heuristic checking for that - with AGP 9 and default settings this looks to be gone
ManeuverIcon looks up the
direction_*drawables by name viaResources.getIdentifier, so the AGP resource shrinker sees no static reference to them and strips all 95 icons from any consumer app built withisShrinkResources = true. BecauseManeuverImagedeliberately ignores resolution failures, the symptom is maneuver icons silently missing in release builds only.This ships a
tools:keeprule inside theui-sharedAAR. Keep files in library resources are merged into the consuming app and honored by the resource shrinker, so consumers get the fix transparently.The file is named
ferrostar_ui_shared_keep.xmlrather than the conventionalkeep.xmlto avoid a resource-merge collision with a consumer's (or another library's) ownres/raw/keep.xml; the shrinker scans all raw XML resources fortools:keepattributes regardless of file name.Verified in a consumer app (AGP 9.x,
isMinifyEnabled = true,isShrinkResources = true): before,build/outputs/mapping/<variant>/resources.txtlisted everydrawable:direction_*as removed; with the rule merged, all 95 reportreachable from keep xml fileand the icons render.